package com.funong.matrix.core.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author lincl
 */

@Getter
@AllArgsConstructor
public enum IsDeletedEnum {
    /**
     * 是否已删除
     */
    NOT_DELETED(0, "未删除"),
    DELETED(1, "删除");

    /**
     * 值
     */
    private Integer value;

    /**
     * 名称
     */
    private String name;

    /**
     * 根据字典值获取枚举类
     *
     * @return
     */
    public static IsDeletedEnum getByValue(Integer value) {
        for (IsDeletedEnum item : IsDeletedEnum.values()) {
            if (item.getValue().equals(value)) {
                return item;
            }
        }
        return null;
    }

    /**
     * 根据字典名获取枚举类
     *
     * @return
     */
    public static IsDeletedEnum getByName(String name) {
        for (IsDeletedEnum item : IsDeletedEnum.values()) {
            if (item.getName().equals(name)) {
                return item;
            }
        }
        return null;
    }

    /**
     * 是否等于某个值
     *
     * @param value
     * @return
     */
    public boolean equals(Integer value) {
        return this.value.equals(value);
    }
}
